<!--Gordana Pejic 191/01-->
<?php
    require '../../pages/db.php';
    $con=dbConnect("sib");

    $name=$_POST["name"];
    $address=$_POST["address"];
    $latitute=$_POST["lat"];
    $longitude=$_POST["long"];
    $pricemin=$_POST["pricemin"];
    $pricemax=$_POST["pricemax"];
    $rooms=$_POST["rooms"];
    $beds=$_POST["beds"];
    $toilets=$_POST["toilets"];
    $included=$_POST["included"];
    $reception=$_POST["reception"];
    $web=$_POST["web"];
    $fooddrink=$_POST["food"];
    $inroom=$_POST["inroom"];
    $todo=$_POST["todo"];
    $general=$_POST["general"];
    $desc=$_POST["desc"];
    $email=$_POST["email"];

    $timest = mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"));
    $today = date("Y-m-d H:i:s", $timest);

    if ($name=="" || $address=="" || $latitute=="" || $longitude=="" || $pricemin=="" || $pricemax==""
        || $rooms=="" || $beds=="" || $toilets=="" || $included=="" || $reception=="" || $web==""
            || $fooddrink=="" || $inroom=="" || $todo=="" || $general=="" || $desc=="" || $email=="")
    {
        echo '<div id="error">ERROR: You must fill in all the gaps!<div/>';
        
    }
    else{
        $sql="INSERT INTO hostel( Name, Address, Latitude, Longitude, NumOfRooms, NumOfBeds, PriceMin, PriceMax,
            CreationDate, IncludedInPrice, Reception, WebAccess, General, FoodDrink, InRoom, ThingsToDo, NumOfToilets,
            Description, Email)
            VALUES('$name', '$address', '$latitute', '$longitude', '$rooms', '$beds', '$pricemin', '$pricemax',
            '$today', '$included', '$reception', '$web', '$general', '$fooddrink', '$inroom', '$todo', '$toilets',
            '$desc', '$email')";
         if (!mysql_query($sql, $con)) {
             die('Error: ' . mysql_error());
         }
         else {
             header('Location: ../hostels-admin.php'); // treba da se pojavi hostel na ovoj stranici!!!

         }
         
    }
    mysql_close($con);
?>
